/* 获取审批记录 */
var firstSpList = true;
var getSpList = function(url){ 
	if(firstSpList) {
		firstSpList = false;
		var winWidth = $('div.jqGrid-border').width();
		var winHeight = $(window).height() / 2.5;
		var win = winWidth / 7 - 20;
		$.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_1").jqGrid({
			postData:{busiId:busiId},
			url:url,
			datatype : "json",
			colNames : ['审批详情','审批批注','业务流程','经办部门', '经办人','处理时间', '处理结果'],
			colModel : [
			            {name: 'auditDetail', hidden:true,formatter:function(a){
			            	return (a && a != "") ? a : '<span style="color:red;">无</span>';
			            }},
			            {name: 'auditPostil', hidden:true,formatter:function(a){
			            	return (a && a != "") ? a : '<span style="color:red;">无</span>';
			            }},
			            {name: 'auditName',index: 'auditName',width: 150,align: "center",sorttype: "float"},
			            {name: 'orgName',index: 'orgName',width: 130,align: "center",sorttype: "float"},
			            {name: 'creatorName',index: 'creatorName',width: 120,align: "center",sorttype: "float"},
			            {name: 'created',index: 'created',width: 160,align: "center",sorttype: "float",formatter:function(a){
			            	return formateIntegerTime(a,'yyyy-MM-dd hh:mm:ss');
			            }},
			            {name: 'auditStatusDisplay',index: 'auditStatus',width: 150,align: "center",sorttype: "float"},
			            ],
			            mtype : "post",
			            height: winHeight,
			            width:winWidth,
			            autowidth: false,
			            shrinkToFit: false,
			            rowNum: 10,
				        rowList: [10, 15, 20, 25, 30],
			            viewrecords: true,
			            pager: "#pager_list_1",
			            hidegrid: false,
			            altRows:true,
			            altclass:'someClass',
			            multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
			            multiboxonly:false,  
			            beforeSelectRow: false,
			            onSelectRow:function(rowId,v,e){
			            	var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
			            	$("#splz_detail").html(rowData.auditDetail);
			            	$("#splz_postilchange").html(rowData.auditPostil);
			            },
			            jsonReader: {
			            	root: "result.rows",
			            	page: "result.page",
			            	total: "result.total",
			            	records: "result.records",
			            	repeatitems: false,
			            	id: "replaceId"
			            },
			            loadComplete:function(datas){
			            	if (datas.flag == "100100") {
			            		if(datas.result.rows && datas.result.rows.length > 0){
			            			var record = datas.result.rows[0];
			            			var auditDetail = record.auditDetail;
			            			$("#splz_detail").html((auditDetail && auditDetail != "") ? auditDetail : '<span style="color:red;">无</span>');
			            			var auditPostil = record.auditPostil;
			            			$("#splz_postilchange").html((auditPostil && auditPostil != "") ? auditPostil : '<span style="color:red;">无</span>');
			            		} else {
			            			$("#splz_detail").html('-');
			            			$("#splz_postilchange").html('-');
			            		}
			            		return;
			            	}
			            	
			            	if(datas.flag == '100802') {
			  				  top.location.href = thisLoginUrl;
			  				  return;
			  			  	}
			            	
			          	  	layer.msg(datas.message, {icon: 2});
			            }
		});
	} else {
		var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
		 $.extend(postData, {dataId:busiId});
        $("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	}
}

function red(id){
	 $('#'+id).removeClass('bg-grey');
	 $('#'+id).removeClass('bg-green');
	 $('#'+id).addClass('bg-red');
}
function green(id) {
	 $('#'+id).removeClass('bg-red');
	 $('#'+id).removeClass('bg-grey');
	 $('#'+id).addClass('bg-green');
}
function grey(id) {
	 $('#'+id).removeClass('bg-red');
	 $('#'+id).removeClass('bg-green');
	 $('#'+id).addClass('bg-grey');
}
function space(id) {
	 $('#'+id).removeClass('bg-red');
	 $('#'+id).removeClass('bg-green');
	 $('#'+id).removeClass('bg-grey');
}